package com.sanqi.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sanqi.common.annotation.Log;
import com.sanqi.common.core.controller.BaseController;
import com.sanqi.common.core.domain.AjaxResult;
import com.sanqi.common.enums.BusinessType;
import com.sanqi.work.domain.WorkTeam;
import com.sanqi.work.service.IWorkTeamService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.sanqi.common.utils.poi.ExcelUtil;
import com.sanqi.common.core.page.TableDataInfo;

/**
 * 班组Controller
 * 
 * @author duany
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/work/team")
@Api(tags="班组")
public class WorkTeamController extends BaseController
{
    @Autowired
    private IWorkTeamService workTeamService;

    /**
     * 查询班组列表
     */
    @PreAuthorize("@ss.hasPermi('work:team:list')")
    @GetMapping("/list")
    @ApiOperation(value="班组-列表", notes="班组-列表")
    public TableDataInfo list(WorkTeam workTeam)
    {
        startPage();
        List<WorkTeam> list = workTeamService.selectWorkTeamList(workTeam);
        return getDataTable(list);
    }

    /**
     * 导出班组列表
     */
    @PreAuthorize("@ss.hasPermi('work:team:export')")
    @Log(title = "班组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value="班组-导出", notes="班组-导出")
    public void export(HttpServletResponse response, WorkTeam workTeam)
    {
        List<WorkTeam> list = workTeamService.selectWorkTeamList(workTeam);
        ExcelUtil<WorkTeam> util = new ExcelUtil<WorkTeam>(WorkTeam.class);
        util.exportExcel(response, list, "班组数据");
    }

    /**
     * 获取班组详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:team:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value="班组-获取班组详细信息", notes="班组-获取班组详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(workTeamService.selectWorkTeamById(id));
    }

    /**
     * 新增班组
     */
    @PreAuthorize("@ss.hasPermi('work:team:add')")
    @Log(title = "班组", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="班组-新增班组", notes="班组-新增班组")
    public AjaxResult add(@RequestBody WorkTeam workTeam)
    {
        return toAjax(workTeamService.insertWorkTeam(workTeam));
    }

    /**
     * 修改班组
     */
    @PreAuthorize("@ss.hasPermi('work:team:edit')")
    @Log(title = "班组", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="班组-修改班组", notes="班组-修改班组")
    public AjaxResult edit(@RequestBody WorkTeam workTeam)
    {
        return toAjax(workTeamService.updateWorkTeam(workTeam));
    }

    /**
     * 删除班组
     */
    @PreAuthorize("@ss.hasPermi('work:team:remove')")
    @Log(title = "班组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="班组-删除班组", notes="班组-删除班组")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workTeamService.deleteWorkTeamByIds(ids));
    }
}
